package org.little.v6;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.little.context.ApplicationContext;
import org.little.context.support.ClassPathXmlApplicationContext;
import org.little.service.v6.IPetStoreService;
import org.little.util.MessageTracker;

import java.util.List;

/**
 * @author Tinyspot
 * @date 2022-06-01 22:46
 */
public class ApplicationContextTest6 {

    @Before
    public void before(){
        MessageTracker.clearMessage();
    }

    @Test
    public void testGetBeanProperty() {

        ApplicationContext context = new  ClassPathXmlApplicationContext("little-v6.xml");
        IPetStoreService petStoreService = (IPetStoreService) context.getBean("petStore");
        petStoreService.placeOrder();

        List<String> messages = MessageTracker.getMessages();
        Assert.assertEquals(3, messages.size());
        Assert.assertEquals("start tx", messages.get(0));
        Assert.assertEquals("place order", messages.get(1));
        Assert.assertEquals("commit tx", messages.get(2));
    }


}
